1. Field of the Invention
The present invention relates to an image processing apparatus, an image processing method, and an image processing program, and more particularly, to an image processing apparatus, an image processing method, and an image processing program, adapted to correct defective pixels of a still camera or a video camera in a highly reliable manner.
2. Description of the Related Art
In a digital still camera, a digital video camera, or a similar camera, an image is taken by sensing the image and converting an optical image signal into a corresponding electric signal using an image sensor (a solid-state image sensor) such as a CCD (Charge Coupled Device) or CMOS (Complementary Metal Oxide Semiconductor) image sensor.
All pixels of an image sensor are not necessarily normal, and defect can occur at some pixels. If defects occur, an image output from the image sensor having defective pixels has deviations of pixel values from correct values at defective pixels, which cause the image to become unnatural.
Note that defects occur at pixels of the image sensor, and the defects of the image sensor cause an image output from the image sensor to have abnormal dots corresponding to the defective pixels. However, hereinafter, for convenience of explanation, a state in which an image sensor has defective pixels will also be described as “an image has defective pixels”.
To prevent a camera from producing an unnatural image caused by defective pixels, it is desirable to detect defective pixels and correct pixel values of the detected defective pixels.
Detection of defective pixels and correction of pixel values of defective pixels may be performed, for example, as follows.
One method of detecting defective pixels is to compare a pixel value of each pixel of an image taken by an image sensor (hereinafter, referred to simple as an image) with a predetermined threshold value and determine, on the basis of the comparison result, whether each pixel is defective.
One method of correcting pixel values of defective pixels is to determine a correct pixel value of each defective pixel from pixel values of pixels located close to the defective pixel according to a proper algorithm. Another method is to determine a correct pixel value of each defective pixel depending on a defective level indicating the degree of defect of each defective pixel.
The threshold value for detecting defective pixels may be a fixed threshold value determined in advance or a variable threshold value dynamically determined depending on pixel values of pixels located close to a pixel of interest being subjected to the comparison of the pixel value with respect to the threshold value.
In the method of determining whether a pixel of interest of an image is defective by comparing the pixel value of the pixel of interest with the predetermined threshold value, if the threshold value is dynamically determined depending on pixel values of pixels located close to the pixel of interest, then the method is equivalent to a method in which a predictive pixel value is determined based on pixel values of pixels located close to the pixel of interest, and the determination as to whether the pixel of interest is defective is made by judging whether the difference between the pixel value of the pixel of interest and the predictive pixel value is within an allowable small range.
For example, in a case where the threshold value is set to be equal to a pixel value p of a pixel adjacent to the pixel of interest plus a fixed margin C, that is, the threshold value is set to p+C, if the pixel of interest has a pixel value v, then the determination as to whether the pixel of interest is defective or not by judging whether the pixel value v is greater than the threshold value p+C is equivalent to the determination made by employing the pixel value p of the pixel adjacent to the pixel of interest as the predictive pixel value and judging whether the difference (v−p) between the pixel value v of the pixel of interest and the predictive pixel value p is within a small range equal to the margin C.
The determination as to whether the pixel of interest is defective is made, as described above, on the basis of the relative magnitude of the pixel value of the pixel of interest with respect to the threshold value. This means that if a defective pixel has a pixel value close to the threshold value, a fluctuation of the pixel value can cause the determination as to whether the pixel of interest is defective to fluctuate between affirmative and negative conclusions.
One technique to prevent the above problem and improve reliability in detection of defective pixels is to evaluate the pixel value of each pixel a plurality of times. More specifically, the pixel value of each pixel is compared with the threshold value for each of a plurality of images captured by the image sensor via an image taking operation performed a plurality of times. If the number of occurrences of detection of defect at a particular pixel position is greater than a predetermined value, then the pixel at this pixel position is determined to be defective (see, for example, Japanese Unexamined Patent Application Publication No. 04-115785 or Japanese Unexamined Patent Application Publication No. 2005-341244).